package com.vcc.msc.sbs;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.widget.TabHost;
import android.widget.TextView;

public class MainActivity extends TabActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.main);

		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, HomeActivity.class);

		// Initialize a TabSpec for each tab and add it to the TabHost
		// Home Tab
		spec = tabHost.newTabSpec("home")
				.setIndicator(makeTabIndicator("Home")).setContent(intent);
		tabHost.addTab(spec);

		// Balance Tab
		intent = new Intent().setClass(this, BalanceActivity.class);
		spec = tabHost.newTabSpec("balance")
				.setIndicator(makeTabIndicator("Balance"))
				// res.getDrawable(R.drawable.manu_button))
				.setContent(intent);
		tabHost.addTab(spec);

		// Operation Tab
		intent = new Intent().setClass(this, OperationActivity.class);
		spec = tabHost.newTabSpec("operation")
				.setIndicator(makeTabIndicator("Operation")).setContent(intent);
		tabHost.addTab(spec);

		// Wes Tab
		intent = new Intent().setClass(this, WesActivity.class);
		spec = tabHost.newTabSpec("wes").setIndicator(makeTabIndicator("WES"))
				.setContent(intent);
		tabHost.addTab(spec);

		// Week report Tab
		intent = new Intent().setClass(this, WeekReportActivity.class);
		spec = tabHost.newTabSpec("weekReport")
				.setIndicator(makeTabIndicator("Week report"))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTab(0);
	}

	private TextView makeTabIndicator(String text) {

		TextView tabView = new TextView(this);
		LayoutParams lp = new LayoutParams(200, 40);
		tabView.setLayoutParams(lp);
		tabView.setText(text);
		tabView.setTextSize(18);
		tabView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
		tabView.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.manu_button));

		return tabView;

	}

}
